package com.loong.controller;

import com.loong.utils.AliOSSUtils;
import com.loong.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;

@RestController
@Slf4j
public class UploadController {
    @Autowired
    AliOSSUtils aliOSSUtils;

    @PostMapping("/upload")
    public Result<String> upload(MultipartFile image) throws IOException {
        String url = aliOSSUtils.upload(image);
        log.info("上传了文件：{}", image.getOriginalFilename());
        return Result.success(url);
    }
}
